home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / mbug9307.zip / HACKER.TXT < prev    next >
Text File  |  1993-07-01  |  6KB  |  124 lines

  1. The Frugal Hacker
  2.  
  3. Bob Stephan
  4.  
  5. hacker n  A person who enjoys exploring the details of programmable
  6. systems and how to stretch their capabilities, as opposed to most
  7. users who prefer to learn only the minimum necessary. (The "New
  8. Hacker's Dictionary", MIT Press, 1991.)
  9.  
  10. BACK TO BATCH.  I keep getting distracted from my main purpose of
  11. discussing the "Out of environment space" problem that can arise
  12. when trying to run batch files that create useful Environment
  13. variables.  This month I will be able to include another
  14. installment.
  15.  
  16. To recap, when a secondary copy of the command processor (usually
  17. COMMAND.COM) is invoked, the Environment block is shrunk down to a
  18. minimum size by MS-DOS.  This usually happens when you run batch
  19. files from one of the many menu or shell programs such as PC Shell,
  20. Xtree, etc.  Only the command processor knows how to run batch
  21. programs so in order for a menu or shell to run a batch program, it
  22. has to start up a copy of  COMMAND.COM or another command processor
  23. such as 4DOS.COM.  The environment space problem is almost entirely
  24. a problem of MS-DOS since other versions appear to be more
  25. intelligent.  In my testing I have found that DR DOS appears to use
  26. the original size of the Environment block as the default size for
  27. secondary copies, and 4DOS is the best of all with a method to
  28. specify what you want as the default.  If you use either DR DOS or
  29. 4DOS you probably don't need to worry about this problem if you
  30. have set your SHELL= command in CONFIG.SYS and/or your 4DOS
  31. parameters correctly.
  32.  
  33. If you tried the last suggestion I made about modifying your
  34. COMSPEC variable to include /E:1024, you have probably found that
  35. it didn't always work, if it worked at all.  This method depends on
  36. some intelligent parsing on the part of the program that "shells
  37. out" to DOS, i.e. invokes the secondary command processor.  Not
  38. many programs or versions of DOS are prepared to deal with this
  39. method.
  40.  
  41. If you happen to have the book "Harnessing DOS 6.0: Batch File and
  42. Command Macro Power" (Menefee & Anis, Bantam, 1993) that I review
  43. in this issue, there is a good dicussion of the problem and some
  44. suggested solutions beginning on page 288.  If you want to get an
  45. advance start on some of the information and methods I will cover
  46. in this and subsequent columns, check out this book.
  47.  
  48. USE A DUMMY.  One of the considerations in deciding on the solution
  49. you want to use is whether the batch files will be run only on your
  50. personal computer, or if you might be programming them to run on
  51. other computers such as setting up systems for several computers in
  52. an office environment.  If the batch files are for your personal
  53. use only, you have more options than if they might be operating in
  54. a DOS system that you cannot control.
  55. The simplest solution for your own system is to reserve the amount
  56. of Environment space you want to maintain with dummy variables.
  57. This is easily done by adding one or more SET commands to your
  58. AUTOEXEC.BAT, or to the batch file that starts your menu program.
  59. With each SET command you can reserve up to about 120 bytes of
  60. Environment space for future use.  Your batch files can then clear
  61. out as much space as they need by simply deleting one or more of
  62. the dummy variables.
  63.  
  64. To establish the dummy variables, you might want to create a
  65. separate batch file that can be called from other batch files as
  66. needed.  Call the file SETDUM.BAT or whatever you want, and just
  67. include one or more statements such as SET DUMMY1=111111. . .11111,
  68. where the entire statement can be up to the DOS limit of 127
  69. characters.  If you think you need more than 120 bytes of free
  70. space, add a SET DUMMY2=222. . .222, etc.  Then in your
  71. AUTOEXEC.BAT, or your batch file that starts your menu program,
  72. simply include the statement CALL SETDUM, using whatever name you
  73. have given to your version of the file.  To free up the reserved
  74. space start your application batch files with the statement SET
  75. DUMMY1=.  You can add more for DUMMY2 and others if needed.
  76.  
  77. To avoid having to modify any of your existing batch files, and to
  78. make sure that the dummy variables are only cleared when needed,
  79. you can use another batch file.  You might call this file
  80. RUNDUM.BAT, and its purpose will be to clear out the dummy
  81. variables and run your application batch file.  RUNDUM.BAT will
  82. consist of two lines:
  83.  
  84. SET DUMMY1=
  85. %1 %2 %3 %4 %5 %6 %7 %8 %9
  86.  
  87. Then, whenever you need to clear out the dummy variables before
  88. running your application batch file you enter:
  89.  
  90. RUNDUM [yourbatch] [parameters]
  91.  
  92. In particular, when you want to run a batch file from within your
  93. shell or menu program, you tell the shell or menu to use the above
  94. command.  For example, if you set up a menu item to run MYPROG.BAT
  95. with a parameter of FILENAME.DOC, then you tell your menu to run
  96. RUNDUM MYPROG FILENAME.DOC.
  97.  
  98. USING GET.  My batch enhancer, GET.EXE, makes extensive use of the
  99. Environment block.  If the "Out of environment space" problem is
  100. due to your use of GET, there is an even simpler method you can
  101. use.  Instead of using some other name for your dummy variable use
  102. the name GET.  In SETDUM.BAT you can use a statement such as SET
  103. GET=gggg. . .ggggg, where you can use up to 127 characters for the
  104. statement.  The rest is automatic.  When GET needs the Environment
  105. space, it will automatically clear out the GET variable and resuse
  106. the space.  You will not need to change your menu items or create
  107. the RUNDUM.BAT file.  A similar method might work with other
  108. programs that require free space in the Environment block.  [To be
  109. continued]
  110.  
  111. DEFINITIONS OF THE MONTH    With apologies to Stan Kelly-Bootle,
  112. author ot The Devil's DP Dictionary, McGraw-Hill, 1981.
  113.  
  114. There are three things a man must do
  115. Before his life is done;
  116. Write two lines in MS BATCH,
  117. And make the buggers run.
  118.  
  119. Bob Stephan welcomes comments and questions that The Frugal Hacker
  120. can respond to.  He can be reached on Internet
  121. (bob.stephan@nitelog.com), NITELOG (408-655-1096), CRICKET
  122. (408-373-3773),  Compu$erve (72357,2276), Plodigy (FNGC05A), or
  123. snail mail at the MBUG-PC address.
  124.